<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://www.bstek.com/dorado" prefix="d" %>
<%@ page import="com.bstek.dorado.data.db.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.bstek.dorado.utils.variant.VariantSet" %>
<%@ page import="com.xr.common.Tools" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>全员照片结构图</title>
 
<style type="text/css">
<!--
.OrgBox{
 font-size:12px;
 padding:5px 5px 5px 5px;
 clear:left;
 float:left;
 text-align:center;
 position:absolute;
 background-image:url(../images/orgPosition.jpg);
 width:70px;
 height:106px;
}
.OrgBox img{
 width:60px;
 height:60px;
}
.OrgBox div{
 color:#FF0500;
 font-weight:800;
}
-->
</style>
<script src="../js/organization.js"></script>
</head>
<body>
<!--<%@ include file="/jsp/js/organization.js" %>-->
  
 <div style="width: 100%; height: 100%; overflow: auto">
 <d:View config="com.xr.org.createOrg">
 
 

 <div id="LoadBox">正在生成，请不要刷新或者关闭窗口,稍后……</div>

 <script language="javascript">
 <%
String comId=request.getParameter("comId");

 
 
 DBStatement dbs=new DBStatement();
 String comSql="select com.*,(select photoid from org_employee where employee_id=com.manager_id)photoid from org_company com start with com.company_id="+comId+" and com.dr=0 connect by prior com.company_id= com.super_company_id";
 String deptSql="select d.*,(select photoid from org_employee where employee_id=d.manager_id)photoid from org_dept d start with d.super_dept_id is null and d.company_id in(select com.company_id from org_company com start with com.company_id = "+comId+" and com.dr = 0 connect by prior com.company_id = com.super_company_id)and d.dr=0 connect by prior d.dept_id = d.super_dept_id";
 String empSql="select oos.onoff_station_id,oos.dept_id,emp.employee_name,emp.photoid,(select p.position_name from pb_position p where p.position_id=oos.position_id)position_name"+
 ",round(months_between(sysdate,oos.work_start_date)/12,1)siling from org_employee emp,org_onoff_station oos where emp.employee_id=oos.employee_id and oos.status=2 and oos.company_id in(select com.company_id from org_company com start with com.company_id = "+comId+" and com.dr = 0 connect by prior com.company_id = com.super_company_id)";
 
 dbs.setSql(comSql);
 List comList=dbs.queryForList();
 dbs.setSql(deptSql);
 List deptList=dbs.queryForList();
  dbs.setSql(empSql);
 List empList=dbs.queryForList();
 
 
 for(int i=0;i<comList.size();i++){
 VariantSet comVs =(VariantSet)comList.get(i);
 %>
 
 if(!window.com<%=comVs.getString("company_id")%>){
 	var com<%=comVs.getString("company_id")%>=new OrgNode();
 	com<%=comVs.getString("company_id")%>.customParam.EmpName='<%=Tools.toStr(comVs.getString("MANAGER_NAME"))%>';
 	com<%=comVs.getString("company_id")%>.customParam.EmpPhoto='../../common/file.output.d?catalog=empPhoto&PHOTOID=<%=comVs.getString("photoid")==null?"0.jpg":comVs.getString("photoid")%>';
 	com<%=comVs.getString("company_id")%>.customParam.department='<%=comVs.getString("company_name")%>';
 	com<%=comVs.getString("company_id")%>.customParam.siling='';
 }
 <%
if(comVs.getString("super_company_id")!=null){%>

 if(!window.com<%=comVs.getString("super_company_id")%>){
 	var com<%=comVs.getString("super_company_id")%>=new OrgNode();
 }
com<%=comVs.getString("super_company_id")%>.Nodes.Add(com<%=comVs.getString("company_id")%>);
<%}%>	

 
<%}%>

<%
for(int i=0;i<deptList.size();i++){
VariantSet deptVs =(VariantSet)deptList.get(i);
%>

if(!window.dept<%=deptVs.getString("dept_id")%>){
 	var dept<%=deptVs.getString("dept_id")%>=new OrgNode();
    dept<%=deptVs.getString("dept_id")%>.customParam.EmpName='<%=Tools.toStr(deptVs.getString("MANAGER_NAME"))%>';
 	dept<%=deptVs.getString("dept_id")%>.customParam.EmpPhoto='../../common/file.output.d?catalog=empPhoto&PHOTOID=<%=deptVs.getString("photoid")==null?"0.jpg":deptVs.getString("photoid")%>';
 	dept<%=deptVs.getString("dept_id")%>.customParam.department='<%=deptVs.getString("dept_name")%>';
 	dept<%=deptVs.getString("dept_id")%>.customParam.siling='';
 }
<%
if(deptVs.getString("super_dept_id")!=null){%>

 if(!window.dept<%=deptVs.getString("super_dept_id")%>){
 	var dept<%=deptVs.getString("super_dept_id")%>=new OrgNode();
 }
dept<%=deptVs.getString("super_dept_id")%>.Nodes.Add(dept<%=deptVs.getString("dept_id")%>);
<%}else{%>
com<%=deptVs.getString("company_id")%>.Nodes.Add(dept<%=deptVs.getString("dept_id")%>);
 <%}%>
 <%}%>

<%
for(int i=0;i<empList.size();i++){
VariantSet empVs =(VariantSet)empList.get(i);
%>

if(!window.emp<%=empVs.getString("onoff_station_id")%>){
 	var emp<%=empVs.getString("onoff_station_id")%>=new OrgNode();
 	emp<%=empVs.getString("onoff_station_id")%>.customParam.EmpName='<%=Tools.toStr(empVs.getString("employee_name").trim())%> ';
 	emp<%=empVs.getString("onoff_station_id")%>.customParam.EmpPhoto='../../common/file.output.d?catalog=empPhoto&PHOTOID=<%=empVs.getString("photoid")==null?"0.jpg":empVs.getString("photoid")%>';
 	emp<%=empVs.getString("onoff_station_id")%>.customParam.department='<%=empVs.getString("position_name")==null?"暂无岗位":empVs.getString("position_name").trim()%>';
	emp<%=empVs.getString("onoff_station_id")%>.customParam.siling= '司龄:<%=empVs.getDouble("siling")%>';   
 }
<%
if(empVs.getString("dept_id")!=null){%>

 if(!window.dept<%=empVs.getString("dept_id")%>){
 	var emp<%=empVs.getString("dept_id")%>=new OrgNode();
 }
dept<%=empVs.getString("dept_id")%>.Nodes.Add(emp<%=empVs.getString("onoff_station_id")%>);
<%}else{%>
dept<%=empVs.getString("dept_id")%>.Nodes.Add(emp<%=empVs.getString("onoff_station_id")%>);
 <%}%>
 <%}%>

var OrgShows=new OrgShow(com<%=comId%>);
OrgShows.Top=50;
OrgShows.Left=50;
OrgShows.IntervalWidth=10;
OrgShows.IntervalHeight=20;
//OrgShows.ShowType=2;
//OrgShows.BoxHeight=100;
OrgShows.BoxTemplet="<div id=\"{Id}\" class=\"OrgBox\"><img src=\"{EmpPhoto}\" /><span>{EmpName}</span><div>{department}</div><div>{siling}</div></div>"
OrgShows.Run();
$("LoadBox").style.display="none";
</script>
<%dbs.close(); %>

 </d:View>
</div>
</body>
</html>
